local jianxiong = fk.CreateSkill {

  name = "joyex__jianxiong",

  tags = {  },

}



jianxiong:addEffect(fk.Damaged, {
  name = "joyex__jianxiong",
  anim_type = "masochism",
  events = {fk.Damaged},
  on_trigger = function(self, event, target, player, data)
    self.cancel_cost = false
    for i = 1, data.damage do
      if self.cancel_cost or player.dead then break end
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askForSkillInvoke(player, jianxiong.name) then
      return true
    end
    self.cancel_cost = true
  end,
  on_use = function(self, event, target, player, data)
    local choice = player.room:askForChoice(player, {"joyex__jianxiong_prey", "draw2"}, jianxiong.name)
    if choice == "joyex__jianxiong_prey" then
      player:drawCards(1, jianxiong.name)
      if not player.dead and data.card and player.room:getCardArea(data.card) == Card.Processing then
        player.room:obtainCard(player, data.card, true, fk.ReasonPrey)
      end
    else
      player:drawCards(2, jianxiong.name)
    end
  end,
})

return jianxiong